Ravi Vishwakarma is a dedicated Software Developer with a passion for crafting efficient and innovative solutions. With a keen eye for detail and years of experience, he excels in developing robust software systems that meet client needs. His expertise spans across multiple programming languages and technologies, making him a valuable asset in any software development project.
ICSM Computer
07-May-2025In C#, you can determine the creation time, last modified time, and last access time of a file using the
File.GetCreationTime,File.GetLastWriteTime, andFile.GetLastAccessTimemethods from theSystem.IOnamespace.Example: Get file timestamps
UTC versions (for consistency across time zones)
File.GetCreationTimeUtc(filePath)File.GetLastWriteTimeUtc(filePath)File.GetLastAccessTimeUtc(filePath)You can also set these times using:
File.SetCreationTime(filePath, DateTime.Now)File.SetLastWriteTime(...)File.SetLastAccessTime(...)Lists timestamps for all files in a folder?
C# example that lists the creation time, last modified time, and last accessed time for all files in a directory:
Optional: Recursively include subfolders
Replace:
With:
This way, you get file timestamps for all files including subdirectories.